package com.pzh.assignment.common.bean.vo;

import com.pzh.assignment.common.bean.GlobalConstant;
import com.pzh.assignment.entity.Major;
import lombok.Data;

import java.time.format.DateTimeFormatter;


@Data
public class MajorVO {
    private Integer id;

    private String name;

    private Integer collegeId;

    private String createTime;

    private String updateTime;

    public static MajorVO valueOf(Major major) {
        MajorVO vo = new MajorVO();
        vo.setId(major.getId());
        vo.setName(major.getName());
        vo.setCollegeId(major.getCollegeId());
        if (major.getCreateTime() != null) {
            vo.setCreateTime(major.getCreateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        if (major.getUpdateTime() != null) {
            vo.setUpdateTime(major.getUpdateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        return vo;
    }
}
